﻿using System;
using System.Runtime.CompilerServices;

namespace ConsoleDemo
{
    public class AttributeExample
    {
        public static void CallerAttributeDemo(string message,
                              [CallerFilePath] string fileName = "",
                              [CallerLineNumber] int lineNumber = 0,
                              [CallerMemberName] string callingMember = "")
        {
            Console.WriteLine("File: {0}", fileName);
            Console.WriteLine("Line: {0}", lineNumber);
            Console.WriteLine("Called From: {0}", callingMember);
            Console.WriteLine("Message: {0}", message);
        }

        //[method: MyAttribute("prints out a message.","Version 3.6")]
        //[return: MyAttribute("This value represents","Version 2.3")]
        public long ReturnSetting()
        {
            return 10000L;
        }
    }

    [System.AttributeUsage(System.AttributeTargets.Class |
                       System.AttributeTargets.Struct)]
    public class AuthorAttribute : System.Attribute
    {
        private string Name;
        public double Version;

        public AuthorAttribute(string name)
        {
            this.Name = name;
            Version = 1.0;
        }

        public string GetName() => Name;
    }
}
